<template>
  <div class="page-content-screen">
    <div class="total">共计 <span style="color: #FF5959;">{{ totalNum}}</span> 条</div>
  </div>
  <div class="page-content-table">
    <vc-table
      :loading="loading"
      :tableData="tableData"
      :columns="columns"
      :total="totalNum"
      :pageSize="PAGE_SIZE"
      :pageNum="queryData.pageNum"
      :defaultSort="{ field: 'noticeDate', order: 'desc' }"
      :maxHeight="500"
      @page-change="handleCurrentChange"
      @sort-change="sortChange"
    />
  </div>
  <vc-dialog v-model="showBondReleaseDetail"
             :title="`${bondReleaseDetails.companyName}发行绿色债券详情`" width="1200"
             height="80vh">
    <div class="detail-table">
      <release-detail-table :companyId="bondReleaseDetails.companyId"></release-detail-table>
    </div>
  </vc-dialog>
</template>
<script lang="ts" setup>
import {getGreenIssueCertification} from '../../../apis';
import {useTable} from './useTable';
import {useScreen} from './useScreen';
import {calculateTableMaxHeight} from "@/utils";
import {usePage} from '@/use/usePage';
import releaseDetailTable from './../../../components/release-detail-table/index.vue';

interface Props {
  companyId: string
}

const {
  companyId
} = defineProps<Props>();
const {PAGE_SIZE, screen, queryData} = useScreen(companyId);
let maxHeight = $ref(0)
queryData.evaluationAgencyCode = companyId
const {data, loading, run} = useRequest(getGreenIssueCertification, {
  defaultParams: [{...queryData}],
  onSuccess: (data) => {
    tableData.value = data.values;
    totalNum.value = data.total;
    nextTick(() => {
      //计算最大高度
      maxHeight = calculateTableMaxHeight()
    })
  }
});
const {
  columns, showBondReleaseDetail, bondReleaseDetails
} = useTable();
const {
  tableData,
  totalNum,
  searchTxt,
  handlerInput,
  handleCurrentChange,
  sortChange
} = usePage(queryData, run);

</script>
<style lang="scss" scoped>
@import "./index.scss";

:deep(.vc-dialog__dialog) {
  left: 0;
  right: 0;
  top: 0;
  transform: translate(0, 0);
}
:deep(.vc-dialog__overlay){
  background: transparent;
}
</style>
